<?php
/**

 * ErrorController - The default error controller class

 * 

 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class ErrorController extends Zend_Controller_Action
{
    
    /**
    
     * This action handles  
    
     *    - Application errors
    
     *    - Errors in the controller chain arising from missing 
    
     *      controller classes and/or action methods
    
     */
    public function errorAction ()
    {
        $this->_helper->viewRenderer->setViewSuffix('phtml');

        $errors = $this->_getParam('error_handler');
        
        switch ($errors->type) {
            
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
            
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404); 
                $this->view->title = 'HTTP/1.1 404 Not Found';                
                break;

            default:
                // application error; display error page, but don't change                
               
                // status code
                $this->getResponse()->setHttpResponseCode(500); 
                $this->view->title = 'Application Error';
                break;
        }

        $this->view->request = $errors->request; 
        $this->view->errorMessage = $errors->exception->getMessage();
        $this->view->errorTrace = $errors->exception->getTraceAsString();

        echo $errors->exception->getMessage();

    }
}
